//
//  EntryProtectDetailVC.m
//  MyProject
//
//  Created by 石小强 on 2018/4/24.
//  Copyright © 2018年 yanjiaming. All rights reserved.
//

#import "EntryProtectDetailVC.h"
#import "EvaluateModel.h"
#import "DecryptProtectView.h"
#import "EntryProtectTargetPositionVC.h"
#import "DecryptModel.h"
#import "AssurePassModel.h"
#import "CommentModel.h"
#import "MoreServicePlanViewController.h"
#import "ApplyDecryptViewController.h"
#import "ProtectBasicDocumentViewController.h"
#import "DecryptAssurePassEvaluateListVC.h"
#import "StringAndIndexModel.h"
#import "ReportOrCancelViewController.h"
#import "WorkmateMainVC.h"
#import "NSUDManager.h"

@interface EntryProtectDetailVC ()

@property (nonatomic, strong) DecryptModel *decryptModel;
@property (nonatomic, strong) AssurePassModel *assurePassModel;
@property (nonatomic, strong) NSMutableArray *commentArray;

@property (nonatomic, strong) UIButton *collectBtn;

@end

@implementation EntryProtectDetailVC {
    BOOL _displayMoreHelpBtn;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupNav];
    _displayMoreHelpBtn = YES;
    
    [self setupTableView];
    
    if (self.index == 1) {
        self.playTitleL.text = @"解密专题服务保障计划";
        self.planContentL.text = @"1.在同事确认申请之前，随时可以无条件退款。\n2.同事确认之后，私聊窗口立即开放，您可以与同事随时沟通解密相关事宜。\n3.平台托管赏金，确认服务器满意才支付给对方。\n4.聊天记录将自动保存本地，方便随时回看或回听。";
        [self loadDecryptDetailData];
        [self loadDecrptCommentsData];
    } else {
        self.playTitleL.text = @"入职保过服务保障计划";
        self.planContentL.text = @"1.在双方确认服务之前，双方可以先互相了解接洽，确认服务合作之后，才需付款。\n2.付款后默认服务期限内，由平台托管赏金，申请者可以随时结束，打赏或退款。\n3.聊天记录将自动保存本地，方便随时回看或回听。";
        
        [self loadAssurePassDetailData];
        [self loadAssurePassCommentsData];
    }
}

/** 设置页面 */
- (void)setupTableView {
    // tableView
    self.tableViewHeaderView.frame = CGRectMake(0, 0, kScreenWidth, 1194);
    self.tableView.backgroundColor = kStyleColor;
    self.tableView.tableHeaderView = self.tableViewHeaderView;
    if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    
    [self setupViewData];
    
    self.tableEvaluateVHeight.constant = 361;

    [self resetTableViewHeaderHeight];
}

- (void)setupViewData {
    if (self.index == 1) {
        self.tableServiceFlowIV.image = [UIImage imageNamed:@"decrypt_detail_flow"];
        self.tablehelperViewTitleL.text = @"你知道吗？";
        self.tablePlanViewImageIV.image = [UIImage imageNamed:@"decrypt_more_plan"];
    } else {
        
        self.tableServiceFlowIV.image = [UIImage imageNamed:@"baoguo_detail_flow"];
        self.tablehelperViewTitleL.text = @"我能帮你";
        self.tablePlanViewImageIV.image = [UIImage imageNamed:@"assurePass_more_plan"];
    }
}

- (IBAction)starViewValueChanged:(id)sender {
    if (self.index == 1) {
        self.headerStarView.value = [self.decryptModel.star floatValue];
    } else {
        self.headerStarView.value = [self.assurePassModel.star floatValue];
    }
}

#pragma mark - 加载数据--解密数据
/** 查询在职者解密服务详情 */
- (void)loadDecryptDetailData {
    WS(weakSelf)
    [self showProgressWithView:self.view animated:YES];
    [SendRequest getIncumbentDecryptDetailsByDecryptId:self.decryptId result:^(NSDictionary *result, NSError *error) {
        [weakSelf hideProgress:self.view animated:YES];
        result = [CommonUtils decryptDicWithResult:result];
        if([result[@"result"] integerValue] == 1) {
            SaintiLog(@"查询在职者解密服务详情 = %@", [result objectForKey:@"data"]);
            weakSelf.decryptModel = [DecryptModel mj_objectWithKeyValues:[result objectForKey:@"data"]];
            [weakSelf resetMainViewData];
        } else {
            [CommonUtils showToast:[result objectForKey:@"msg"]];
        }
    }];
}

- (void)loadDecrptCommentsData {
    WS(weakSelf)
    [SendRequest getIncumbentServiceCommentsByServiceId:self.decryptId  andServiceType:@"DECRYPT" andPageNo:@"1" result:^(NSDictionary *result, NSError *error) {
        result = [CommonUtils decryptDicWithResult:result];
        if([result[@"result"] integerValue] == 1) {
            SaintiLog(@"查询在职者解密评论数据 = %@", [result objectForKey:@"data"]);
            
            NSArray *datas = [CommentModel mj_objectArrayWithKeyValuesArray:[[result objectForKey:@"data"] objectForKey:@"list"]];
            [weakSelf.commentArray removeAllObjects];
            [weakSelf.commentArray addObjectsFromArray:datas];
//            [weakSelf resetMainViewData];
            [weakSelf resetEvaluateView];
        } else {
            [CommonUtils showToast:[result objectForKey:@"msg"]];
        }
    }];
}

#pragma mark - 加载数据--保过数据
/** 查询在职者解密服务详情 */
- (void)loadAssurePassDetailData {
    WS(weakSelf)
    [self showProgressWithView:self.view animated:YES];
    [SendRequest getIncumbentAssurePassDetailsByAssurePassId:self.assurePassId result:^(NSDictionary *result, NSError *error) {
        [weakSelf hideProgress:self.view animated:YES];
        result = [CommonUtils decryptDicWithResult:result];
        if([result[@"result"] integerValue] == 1) {
            SaintiLog(@"查询在职者解密服务详情 = %@", [result objectForKey:@"data"]);
            weakSelf.assurePassModel = [AssurePassModel mj_objectWithKeyValues:[result objectForKey:@"data"]];
            [weakSelf resetMainViewData];
        } else {
            [CommonUtils showToast:[result objectForKey:@"msg"]];
        }
    }];
}

- (void)loadAssurePassCommentsData {
    WS(weakSelf)
    [SendRequest getIncumbentServiceCommentsByServiceId:self.assurePassId  andServiceType:@"ASSURE_PASS" andPageNo:@"1" result:^(NSDictionary *result, NSError *error) {
        result = [CommonUtils decryptDicWithResult:result];
        if([result[@"result"] integerValue] == 1) {
            SaintiLog(@"查询在职者解密评论数据 = %@", [result objectForKey:@"data"]);
            
            NSArray *datas = [CommentModel mj_objectArrayWithKeyValuesArray:[[result objectForKey:@"data"] objectForKey:@"list"]];
            [weakSelf.commentArray removeAllObjects];
            [weakSelf.commentArray addObjectsFromArray:datas];
//            [weakSelf resetMainViewData];
            [weakSelf resetEvaluateView];
        } else {
            [CommonUtils showToast:[result objectForKey:@"msg"]];
        }
    }];
}

#pragma mark - 请求完数据后，刷新页面
- (void)resetMainViewData {
    if (self.index == 1) {
        // 头部
        self.headerTitleL.text = self.decryptModel.title;
        self.headerPriceL.text = [NSString stringWithFormat:@"￥%@", self.decryptModel.price];
        self.headerEvaluateL.text = [NSString stringWithFormat:@"%@条评价", self.decryptModel.evaluateCount];
        self.headerStarView.value = [self.decryptModel.star floatValue];
        [self.headerIconIV sd_setImageWithURL:ImageURLWithKey(self.decryptModel.publisherHeadImg) placeholderImage:PlaceholderImagePeople];
        
//        NSString *result = (self.decryptModel.publisher && self.decryptModel.publisher.length > 0) ? self.decryptModel.publisher : @"";
//        if (self.decryptModel.publisherPosition && self.decryptModel.publisherPosition.length > 0) {
//            result = [NSString stringWithFormat:@"%@ | %@", result, self.decryptModel.publisherPosition];
//        }
//        if (self.decryptModel.publisherCompany && self.decryptModel.publisherCompany.length > 0) {
//            result = [NSString stringWithFormat:@"%@ | %@", result, self.decryptModel.publisherCompany];
//        }
//        self.headerNameL.text = self.decryptModel.publisher;
//        self.headerPositionL.text = self.assurePassModel.publisherPosition;
//        self.headerCompanyL.text = self.assurePassModel.publisherCompany;
        
        if (self.decryptModel.publisher && self.decryptModel.publisher.length > 0) {
            self.headerNameL.text = self.decryptModel.publisher;
        }
        if (self.decryptModel.publisherPosition && self.decryptModel.publisherPosition.length > 0) {
            self.headerNameLineV.hidden = NO;
            self.headerPositionL.text = self.decryptModel.publisherPosition;
        } else {
            self.headerNameLineV.hidden = YES;
        }
        if (self.decryptModel.publisherCompany && self.decryptModel.publisherCompany.length > 0) {
            self.headerPositionLineV.hidden = NO;
            self.headerCompanyL.text = self.decryptModel.publisherCompany;
        } else {
            self.headerPositionLineV.hidden = YES;
        }
        
        
        // 谁能帮你
        if (self.decryptModel.details && self.decryptModel.details.length > 0) {
            self.tableHelperDescL.text = self.decryptModel.details;
            
            CGFloat descH = [Tool sizeWithText:self.decryptModel.details font:[UIFont fontWithName:@"PingFang SC" size:13] maxW:(kScreenWidth - 53)].height;
            NSInteger lineCount = descH / self.tableHelperDescL.font.lineHeight;
            
            if (lineCount < 3) {
                self.tableHelperMoreBtn.hidden = YES;
                self.tableHelperLine.hidden = YES;
                
                self.tableHelperDescL.numberOfLines = lineCount == 0 ? 1 : lineCount;
                _displayMoreHelpBtn = NO;
                self.tableHelperMoreBtnHeight.constant = 0;
            } else {
                self.tableHelperMoreBtn.hidden = NO;
                self.tableHelperLine.hidden = NO;
                
                self.tableHelperDescL.numberOfLines = 3;
                _displayMoreHelpBtn = YES;
                self.tableHelperMoreBtnHeight.constant = 40;
            }
            
            self.tablehelperViewTitleL.hidden = NO;
            self.tableHelperViewIndicatorView.hidden = NO;
            self.tableHelperV.hidden = NO;
            self.tableHelperViewTopHeight.constant = 15;
        } else {
            self.tableHelperDescL.text = @"";
            self.tablehelperViewTitleL.hidden = YES;
            self.tableHelperViewIndicatorView.hidden = YES;
            self.tableHelperV.hidden = YES;
            self.tableHelperViewTopHeight.constant = 0;
            _displayMoreHelpBtn = NO;
            self.tableHelperMoreBtnHeight.constant = 0;
        }
        
        [self resetTableViewHeaderHeight];
        // 评价
//        [self resetEvaluateView];
    } else {
        // 头部
        self.headerTitleL.text = [NSString stringWithFormat:@"【%@】入职保过", self.assurePassModel.jobName];
        self.headerPriceL.text = [NSString stringWithFormat:@"￥%@", self.assurePassModel.price];
        self.headerEvaluateL.text = [NSString stringWithFormat:@"%@条评价", self.assurePassModel.evaluateCount];
        self.headerStarView.value = [self.assurePassModel.star floatValue];
        [self.headerIconIV sd_setImageWithURL:ImageURLWithKey(self.assurePassModel.publisherHeadImg) placeholderImage:PlaceholderImagePeople];
        
//        NSString *result = (self.assurePassModel.publisher && self.assurePassModel.publisher.length > 0) ? self.assurePassModel.publisher : @"";
//        if (self.assurePassModel.publisherPosition && self.assurePassModel.publisherPosition.length > 0) {
//            result = [NSString stringWithFormat:@"%@ | %@", result, self.assurePassModel.publisherPosition];
//        }
//        if (self.assurePassModel.publisherCompany && self.assurePassModel.publisherCompany.length > 0) {
//            result = [NSString stringWithFormat:@"%@ | %@", result, self.assurePassModel.publisherCompany];
//        }
//        self.headerNameL.text = self.assurePassModel.publisher;
//        self.headerPositionL.text = self.assurePassModel.publisherPosition;
//        self.headerCompanyL.text = self.assurePassModel.publisherCompany;
        
        if (self.assurePassModel.publisher && self.assurePassModel.publisher.length > 0) {
            self.headerNameL.text = self.assurePassModel.publisher;
        }
        if (self.assurePassModel.publisherPosition && self.assurePassModel.publisherPosition.length > 0) {
            self.headerNameLineV.hidden = NO;
            self.headerPositionL.text = self.assurePassModel.publisherPosition;
        } else {
            self.headerNameLineV.hidden = YES;
        }
        if (self.assurePassModel.publisherCompany && self.assurePassModel.publisherCompany.length > 0) {
            self.headerPositionLineV.hidden = NO;
            self.headerCompanyL.text = self.assurePassModel.publisherCompany;
        } else {
            self.headerPositionLineV.hidden = YES;
        }
        
        // 谁能帮你
        if (self.assurePassModel.details && self.assurePassModel.details.length > 0) {
            self.tableHelperDescL.text = self.assurePassModel.details;
            
            CGFloat descH = [Tool sizeWithText:self.assurePassModel.details font:[UIFont fontWithName:@"PingFang SC" size:13] maxW:(kScreenWidth - 53)].height;
            NSInteger lineCount = descH / self.tableHelperDescL.font.lineHeight;
            
            if (lineCount < 3) {
                self.tableHelperMoreBtn.hidden = YES;
                self.tableHelperLine.hidden = YES;
                
                self.tableHelperDescL.numberOfLines = lineCount == 0 ? 1 : lineCount;
                _displayMoreHelpBtn = NO;
                self.tableHelperMoreBtnHeight.constant = 0;
            } else {
                self.tableHelperMoreBtn.hidden = NO;
                self.tableHelperLine.hidden = NO;
                
                self.tableHelperDescL.numberOfLines = 3;
                _displayMoreHelpBtn = YES;
                self.tableHelperMoreBtnHeight.constant = 40;
            }
            
            self.tablehelperViewTitleL.hidden = NO;
            self.tableHelperViewIndicatorView.hidden = NO;
            self.tableHelperV.hidden = NO;
            self.tableHelperViewTopHeight.constant = 15;
        } else {
            self.tableHelperDescL.text = @"";
            self.tablehelperViewTitleL.hidden = YES;
            self.tableHelperViewIndicatorView.hidden = YES;
            self.tableHelperV.hidden = YES;
            self.tableHelperViewTopHeight.constant = 0;
            _displayMoreHelpBtn = NO;
            self.tableHelperMoreBtnHeight.constant = 0;
        }
        
        [self resetTableViewHeaderHeight];
        // 评价
//        [self resetEvaluateView];
    }
}

- (void)resetEvaluateView {
    for (UIView *vi in self.tableEvaluateV.subviews) {
        if (vi.tag > 5) {
            [vi removeFromSuperview];
        }
        
        if (self.commentArray.count == 0) {
            self.tableEvaluateVHeight.constant = 0;
        } else {
            if (self.commentArray.count == 1) {  // 只显示一条
                CommentModel *one = [self.commentArray objectAtIndex:0];
                // totalH = 169
                CGSize descS = [Tool sizeWithText:one.content font:[UIFont fontWithName:@"PingFangSC-Regular" size:14] maxW:kScreenWidth - 30];
                NSString *replyStr;
                CGFloat replayHeight = 0;
                if (one.comments.count > 0) {
                    CommentModel *comment = [one.comments objectAtIndex:0];
                    if (comment.content && comment.content.length > 0) {
                        replyStr = [NSString stringWithFormat:@"同事回复：%@", comment.content];
                        replayHeight = [Tool sizeWithText:replyStr font:[UIFont fontWithName:@"PingFang SC" size:12] maxW:kScreenWidth - 30].height;
                    } else {
                        replyStr = @"";
                        replayHeight = 0;
                    }
                } else {
                    replyStr = @"";
                    replayHeight = 0;
                }
                
                CGFloat protectVH = 65 + descS.height + 15 + replayHeight + 31;
                DecryptProtectView *oneV = [[DecryptProtectView alloc] initWithFrame:CGRectMake(0, 37, kScreenWidth, protectVH)];
                oneV.model = one;
                oneV.headerIconBlock = ^(NSString *userId) {
                    WorkmateMainVC *vc = [[WorkmateMainVC alloc] init];
                    vc.userId = userId;
                    [self.navigationController pushViewController:vc animated:YES];
                };
                [self.tableEvaluateV addSubview:oneV];
                
                self.tableEvaluateVHeight.constant = 37 + protectVH;
            } else {  // 显示两条
                CommentModel *one = [self.commentArray objectAtIndex:0];
                CGSize descS = [Tool sizeWithText:one.content font:[UIFont fontWithName:@"PingFangSC-Regular" size:14] maxW:kScreenWidth - 30];
                NSString *replyStr;
                CGFloat replayHeight = 0;
                if (one.comments.count > 0) {
                    CommentModel *comment = [one.comments objectAtIndex:0];
                    if (comment.content && comment.content.length > 0) {
                        replyStr = [NSString stringWithFormat:@"同事回复：%@", comment.content];
                        replayHeight = [Tool sizeWithText:replyStr font:[UIFont fontWithName:@"PingFang SC" size:12] maxW:kScreenWidth - 30].height;
                    } else {
                        replyStr = @"";
                        replayHeight = 0;
                    }
                } else {
                    replyStr = @"";
                    replayHeight = 0;
                }
                
                CGFloat protectVH = 65 + descS.height + 15 + replayHeight + 31;
                DecryptProtectView *oneV = [[DecryptProtectView alloc] initWithFrame:CGRectMake(0, 37, kScreenWidth, protectVH)];
                oneV.model = one;
                oneV.headerIconBlock = ^(NSString *userId) {
                    WorkmateMainVC *vc = [[WorkmateMainVC alloc] init];
                    vc.userId = userId;
                    [self.navigationController pushViewController:vc animated:YES];
                };
                [self.tableEvaluateV addSubview:oneV];
                
                
                CommentModel *two = [self.commentArray objectAtIndex:1];
                CGSize descST = [Tool sizeWithText:two.content font:[UIFont fontWithName:@"PingFangSC-Regular" size:14] maxW:kScreenWidth - 30];
                NSString *replyStrT;
                CGFloat replayHeightT = 0;
                if (two.comments.count > 0) {
                    CommentModel *commentT = [two.comments objectAtIndex:0];
                    if (commentT.content && commentT.content.length > 0) {
                        replyStr = [NSString stringWithFormat:@"同事回复：%@", commentT.content];
                        replayHeightT = [Tool sizeWithText:replyStrT font:[UIFont fontWithName:@"PingFang SC" size:12] maxW:kScreenWidth - 30].height;
                    } else {
                        replyStrT = @"";
                        replayHeightT = 0;
                    }
                } else {
                    replyStrT = @"";
                    replayHeightT = 0;
                }
                
                CGFloat protectVHT = 65 + descST.height + 15 + replayHeightT + 31;
                DecryptProtectView *twoV = [[DecryptProtectView alloc] initWithFrame:CGRectMake(0, 37 + protectVH + 15, kScreenWidth, protectVHT)];
                twoV.model = two;
                twoV.headerIconBlock = ^(NSString *userId) {
                    WorkmateMainVC *vc = [[WorkmateMainVC alloc] init];
                    vc.userId = userId;
                    [self.navigationController pushViewController:vc animated:YES];
                };
                [self.tableEvaluateV addSubview:twoV];
                
                self.tableEvaluateVHeight.constant = 37 + protectVH + 15 + protectVHT;
            }
        }
    }
    [self resetTableViewHeaderHeight];
}

#pragma mark - 按钮点击事件
/** 点击查看更多按钮点击事件 */
- (IBAction)tableHelperMoreBtnClick:(id)sender {
    self.tableHelperMoreBtn.selected = !self.tableHelperMoreBtn.selected;
    
//    NSString *helpDescStr = @"通过这几年大大小小的面试、总结以及与前辈的交流，我给自己大致设定了一个回答问题的模板：1.简单的背景介绍。第一部分，简单介绍这样的信息。2.相关工作经验介绍第二部分，举出几个与你面试职相关的工作/实习经历。几个需要注意的点—— A. 不要只罗列，要用具体事例向面试官证明你做到了么，达成了什么。";
//    self.tableHelperDescL.text = helpDescStr;
    
    if (self.tableHelperMoreBtn.selected) {
        self.tableHelperDescL.numberOfLines = 0;
    } else {
        self.tableHelperDescL.numberOfLines = 3;
    }
    
    [self resetTableViewHeaderHeight];
}
/** 更多评价按钮点击事件 */
- (IBAction)tableEvaluateMoreBtnClick:(id)sender {
    DecryptAssurePassEvaluateListVC *vc = [[DecryptAssurePassEvaluateListVC alloc] init];
    if (self.index == 1) {
        vc.serviceId = self.decryptId;
        vc.serviceType = @"DECRYPT";
    } else {
        vc.serviceId = self.assurePassId;
        vc.serviceType = @"ASSURE_PASS";
    }
    [self.navigationController pushViewController:vc animated:YES];
}
/** 更多信任与保障按钮点击事件 */
- (IBAction)tablePlanMoreBtnClick:(id)sender {
    MoreServicePlanViewController *plan = [[MoreServicePlanViewController alloc] init];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:plan];
    [self presentViewController:nav animated:NO completion:nil];
}
- (IBAction)submitApplyBtnClick:(id)sender {
    if (self.index == 1) {
        if ([[NSUDManager currentUser].userId isEqualToString:self.decryptModel.publisherId] || [[NSUDManager currentUser].userId integerValue] == [self.decryptModel.publisherId integerValue]) {
            [CommonUtils showToast:@"不能申请自己的解密问答"];
        } else {
            ApplyDecryptViewController *apply = [[ApplyDecryptViewController alloc] init];
            apply.price = self.decryptModel.price;
            apply.titleStr = self.decryptModel.title;
            apply.incumbentDecryptId = self.decryptModel.incumbentDecryptId;
            [self.navigationController pushViewController:apply animated:YES];
        }
    } else {
        if ([[NSUDManager currentUser].userId isEqualToString:self.assurePassModel.publisherId] || [[NSUDManager currentUser].userId integerValue] == [self.assurePassModel.publisherId integerValue]) {
            [CommonUtils showToast:@"不能申请自己的保过问答"];
        } else {
            ProtectBasicDocumentViewController *position = [[ProtectBasicDocumentViewController alloc] init];
            position.companyId = self.companyId;
            position.assurePassId = self.assurePassId;
            [self.navigationController pushViewController:position animated:YES];
        }
    }
}

#pragma mark - 重新设计高度

- (void)resetTableViewHeaderHeight {
    [self.tableHelperDescL sizeToFit];
    
    // 144 + helpH + self.tableEvaluateVHeight.constant + 服务流程 + 196
    CGFloat help_more_btn_h = _displayMoreHelpBtn ? 44 : 0;
    CGFloat helpH = 43 + self.tableHelperDescL.mj_h + help_more_btn_h;
    if (self.tableHelperViewTopHeight.constant == 0) {
        helpH = 0;
    }
    
    CGFloat flowH = 37 + (kScreenWidth - 30) * 105 / 345;
    self.tableServiceFlowHeight.constant = flowH;
    
    CGFloat planH = (kScreenWidth - 30) * 332 / 694;
    self.tablePlanViewHeight.constant = planH;
    
//    CGFloat height = 144 + helpH + self.tableEvaluateVHeight.constant + flowH + 196 + 15;
    CGFloat height = 129 + self.tableHelperViewTopHeight.constant + helpH + self.tableEvaluateVHeight.constant + flowH + 15 + planH + 15 + 15;
    self.tableViewHeaderView.frame = CGRectMake(0, 0, kScreenWidth, height);
    self.tableView.tableHeaderView = self.tableViewHeaderView;
    [self.tableView reloadData];
}

#pragma mark - 导航栏模块
- (void)setupNav {
    if (self.index == 1) {
        self.navigationItem.title = @"解密私聊详情";
    } else if (self.index == 2) {
        self.navigationItem.title = @"入职保过详情";
    }
    
    UIButton *tipB = [[UIButton alloc] init];
    [tipB setImage:[UIImage imageNamed:@"ic_tip_black"] forState:UIControlStateNormal];
    [tipB setMj_size:tipB.currentImage.size];
    [tipB addTarget:self action:@selector(tipBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *shareB = [[UIButton alloc] init];
    [shareB setImage:[UIImage imageNamed:@"ic_share_black"] forState:UIControlStateNormal];
    [shareB setMj_size:shareB.currentImage.size];
    [shareB addTarget:self action:@selector(shareBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *collectB = [[UIButton alloc] init];
    [collectB setImage:[UIImage imageNamed:@"ic_collect_unselect_black"] forState:UIControlStateNormal];
    [collectB setImage:[UIImage imageNamed:@"ic_collect_select_black"] forState:UIControlStateSelected];
    [collectB setMj_size:collectB.currentImage.size];
    [collectB addTarget:self action:@selector(collectBtnClick) forControlEvents:UIControlEventTouchUpInside];
    self.collectBtn = collectB;
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:shareB];
//    self.navigationItem.rightBarButtonItems = @[[[UIBarButtonItem alloc] initWithCustomView:tipB], [[UIBarButtonItem alloc] initWithCustomView:nil], [[UIBarButtonItem alloc] initWithCustomView:shareB], [[UIBarButtonItem alloc] initWithCustomView:nil], [[UIBarButtonItem alloc] initWithCustomView:collectB]];
    self.navigationItem.rightBarButtonItems = @[[[UIBarButtonItem alloc] initWithCustomView:tipB], [[UIBarButtonItem alloc] initWithCustomView:nil], [[UIBarButtonItem alloc] initWithCustomView:shareB]];
}

#pragma mark - 导航栏按钮点击事件

- (void)tipBtnClick {
    NSArray *msgs = @[@"信息内容不真实", @"泄露/索取个人隐私", @"封建迷信、反动思想、涉黄涉暴等政治敏感内容", @"发布广告/虚假信息/传销等信息", @"辱骂/诽谤/恶意骚扰等人身攻击", @"其他"];
    NSMutableArray *dataArray = [[NSMutableArray alloc] init];
    for (NSInteger i = 0; i < msgs.count; i++) {
        StringAndIndexModel *model = [[StringAndIndexModel alloc] init];
        if (i == 0) {
            model.index = 1;
        } else {
            model.index = 0;
        }
        model.msg = msgs[i];
        [dataArray addObject:model];
    }
    
    ReportOrCancelViewController *vc = [[ReportOrCancelViewController alloc] init];
    vc.index = 1;
    vc.dataArray = dataArray;
    if (self.index == 1) {
        vc.relatedId = self.decryptId;
        vc.relatedType = @"REPORT_TYPE_DECRYPT";
    } else {
        vc.relatedId = self.assurePassId;
        vc.relatedType = @"REPORT_TYPE_ASSURE_PASS";
    }
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)shareBtnClick {
    [self showShareView];
}

- (void)collectBtnClick {
    self.collectBtn.selected = !self.collectBtn.selected;
}

#pragma mark - UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"EntryProtectDetailCell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"EntryProtectDetailCell"];
    }
    cell.backgroundColor = kStyleColor;
    cell.textLabel.text = @"ssssssssssssssssss";
    return cell;
}

- (NSMutableArray *)commentArray {
    if (!_commentArray) {
        _commentArray = [[NSMutableArray alloc] init];
    }
    return _commentArray;
}

@end
